﻿
@{
    ViewBag.Title = "SysMedicine";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function () {
        gridList();

    })
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            treeGrid: true,
            treeGridModel: "adjacency",
            url: "/SystemManage/SysChargeItem/GetsfGridJson",
            height: $(window).height() - 96,
            colModel: [
                { label: "主键", name: "id", hidden: true, key: true },
                { label: "药品代码", name: "sfxm", width: 80, align: 'left' },
                { label: '药品名称', name: 'sfxmmc', width: 100, align: 'left' },
                { label: '商品名', name: 'py', width: 50, align: 'left' },
                { label: '拼音', name: 'dw', width: 50, align: 'left' },
                { label: '包装单位', name: 'dj', width: 50, align: 'left' },
                { label: '门诊拆零数', name: 'dl', width: 100, align: 'left' },
                { label: '门诊拆零单位', name: 'fl', width: 100, align: 'left' },
                { label: '住院拆零数', name: 'zfbl', width: 50, align: 'left' },
                { label: '住院拆零单位', name: 'zfxz', width: 50, align: 'left' },
                { label: '定价单位', name: 'ybdm', width: 50, align: 'left' },
                { label: '自负比例', name: 'wjdm', width: 50, align: 'left' },
                {
                    label: '范围', name: 'mzzybz', width: 80, align: 'left',
                    formatter: function (cellvalue) {
                        if (cellvalue == "0") {
                            return "通用";
                        } else if (cellvalue == "1") {
                            return "门诊";
                        } else if (cellvalue == "2") {
                            return "住院";
                        } else {
                            return "";
                        }
                    }
                }, { label: '实施', name: 'ssbz', width: 50, align: 'left' },
                       { label: '特殊', name: 'tsbz', width: 50, align: 'left' },
                         { label: '收费项', name: 'sfbz', width: 50, align: 'left' },
                {
                    label: '有效', name: 'zt', width: 50, align: 'left',
                    formatter: function (cellvalue) {
                        if (cellvalue == 0) {
                            return "无效"
                        } else {
                            return "有效"
                        }
                    }
                },
                { label: '建档人员', name: 'jdry', width: 50, align: 'left' },
                {
                    label: '建档日期', name: 'jdrq', width: 50, align: 'left',
                    formatter: "date", formatoptions: { srcformat: 'Y-m-d', newformat: 'Y-m-d' }
                }
            ]
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { keyword: $("#txt_keyword").val() },
            }).trigger('reloadGrid');
        });
    }
    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "系统药品添加",
            url: "/Medicine/SysMedicineAdd",
            width: "700px",
            height: "420px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_edit() {
        var keyValue = $("#gridList").jqGridRowValue().id;
        $.modalOpen({
            id: "Form",
            title: "修改信息",
            url: "/SystemManage/SysChargeItem/Form?keyValue=" + keyValue,
            width: "700px",
            height: "520px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_delete() {
        $.deleteForm({
            url: "/SystemManage/SysChargeItem/DeleteForm",
            param: { keyValue: $("#gridList").jqGridRowValue().id },
            success: function () {
                $.currentWindow().$("#gridList").resetSelection();
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
    function btn_details() {
        var keyValue = $("#gridList").jqGridRowValue().id;
        $.modalOpen({
            id: "Details",
            title: "查看机构",
            url: "/SystemManage/SysChargeItem/Form?keyValue=" + keyValue,
            width: "700px",
            height: "560px",
            btn: null,
        });
    }
    function submitForm() {
        if (!$('#form1').formValid()) {
            return false;
        }
        $.submitForm({
            url: "/SystemManage/SysChargeItem/SubmitForm?keyValue=" + keyValue,
            param: $("#form1").formSerialize(),
            success: function () {
                $.currentWindow().$("#gridList").resetSelection();
                $.currentWindow().$("#gridList").trigger("reloadGrid");
                $.loading(false);
            }
        })
    }
</script>
<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="btn-group">
            <a id="NF-add" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>新建项目</a>
        </div>
        <div class="operate">
            <ul class="nav nav-pills">
                <li class="first">已选中<span>1</span>项</li>
                <li><a id="NF-edit" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修改信息</a></li>
                <li><a id="NF-delete" onclick="btn_delete()"><i class="fa fa-trash-o"></i>删除信息</a></li>
                <li><a id="NF-Details" onclick="btn_details()"><i class="fa fa-search-plus"></i>查看信息</a></li>
            </ul>
            <a href="javascript:;" class="close"></a>
        </div>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="请输入要查询关键字" style="width: 200px;">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
</div>

